/*
 * ChooseDeliveryActivity.java
 * business
 *
 * Created by ChenTao on 2017/2/14.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.main.shoppingcart.choosedelivery;

import android.app.Activity;
import android.content.Intent;

import com.yidiandao.business.R;
import com.yidiandao.business.base.BaseActivity;
import com.yidiandao.business.constant.Intents;
import com.yidiandao.business.data.model.ConfirmOrderModel;
import com.yidiandao.business.utils.ActivityUtils;

/**
 * 选择配送方式 Activity
 * <p>
 * <p>Created by ChenTao(chentao7v@gmail.com) on 2017/2/14 9:38
 */
public class ChooseShippingWayActivity extends BaseActivity {

    private ChooseShoppingWayFragment mChooseShoppingWayFragment;

    public static void actionStart(Activity activity, String addressId) {
        Intent intent = new Intent(activity, ChooseShippingWayActivity.class);
        intent.putExtra(Intents.EXTRA_ADDRESS_ID, addressId);
        activity.startActivity(intent);
    }

    @Override
    protected void initFragment() {
        mChooseShoppingWayFragment = (ChooseShoppingWayFragment)
                getSupportFragmentManager().findFragmentById(R.id.container_choose_delivery);

        if (mChooseShoppingWayFragment == null) {
            mChooseShoppingWayFragment = ChooseShoppingWayFragment.getInstance(
                    getIntent().getExtras());
            ActivityUtils.addFragmentToActivity(
                    getSupportFragmentManager(),
                    mChooseShoppingWayFragment,
                    R.id.container_choose_delivery);
        }
    }

    @Override
    protected void initPresenter() {
        new ChooseShippingWayPresenter(mChooseShoppingWayFragment, new ConfirmOrderModel());
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_choose_shipping_way;
    }
}
